<?php
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) { 

require_once('common/connectdb.php');

      // Temporary file name stored on the server
      $tmpName  = $_FILES['image']['tmp_name'];  

      // Read the file 
      $fp      = fopen($tmpName, 'r');
      $data = fread($fp, filesize($tmpName));
      $data = addslashes($data);
	fclose($fp);


	$ConnectDB = new ConnectDB();
	$qImage  = "INSERT INTO tb_images (image) VALUES ('$data')";
	$rImage  = $ConnectDB->run_query($qImage, TRUE);
      	$imageID = $rImage[1];

      	print "$imageID";

}
else {
   print "0";
}

?>
